package com.dou.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dou.entity.Order;
import com.dou.entity.User;
import com.dou.service.OrderService;
import com.dou.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Reference//使用user项目中的服务
    private UserService userService;
    @RequestMapping("helloworld")
    public String hello(){
        return "hello world";
    }
    @RequestMapping("order")
    @ResponseBody
    public List<Order> user(){
        return orderService.getAllOrder();
    }
    //调用user服务方法
    @RequestMapping("query")
    @ResponseBody
    public List<User> query(){
        return userService.getAllUser();
    }
}
